<template>
	<view>
		<view>
			<view style="height: 100upx;display: flex;background-color: #fff;margin-top: 20upx;">
				<view style="line-height: 100upx;margin-left: 50upx;font-size: 35upx;">
					银行信息
				</view>
				<view style="line-height: 100upx;margin-left: 30upx;">
					{{bank}}
				</view>
			</view>
			<view style="height: 100upx;display: flex;background-color: #fff;margin-top: 20upx;">
				<view style="line-height: 100upx;margin-left: 50upx;font-size: 35upx;">
					开户信息
				</view>
				<view style="line-height: 100upx;margin-left: 30upx;">
					{{bankpeople}}
				</view>
			</view>
			<view style="height: 100upx;display: flex;background-color: #fff;margin-top: 20upx;">
				<view style="line-height: 100upx;margin-left: 50upx;font-size: 35upx;">
					账户信息
				</view>
				<view style="line-height: 100upx;margin-left: 30upx;">
					{{bankcard}}
				</view>
			</view>
		</view>
		<view>
			<view style="background-color: #fff;margin-top: 20upx;">
				<view style="line-height: 100upx;border-bottom: 1upx solid #ccc;">
					<text style="margin-left: 50upx;font-size: 35upx;">用户须知</text>
				</view>
				<view style="margin-left: 30upx;">
					<view style="line-height: 100upx;margin-left: 50upx;">
						1.用户保存银行账户信息
					</view>
					<view style="line-height: 100upx;margin-left: 50upx;">
						2.前往银行完成打款之后截图保存您的付款凭证
					</view>
					<view style="line-height: 100upx;margin-left: 50upx;">
						3.在此页面进行付款凭证截图上传
					</view>
					<view style="line-height: 100upx;margin-left: 50upx;">
						4.后台审核通过之后会进行及时入账
					</view>
				</view>
			</view>
		</view>
		<view class="" style="text-align: center;margin-top: 20upx;background-color: #fff;height: 300upx;">
			<image @click="chooseImage" style="width: 250upx;height: 250upx;margin-top: 25upx;" :src="avatar || backgroundImg" mode=""></image>
		</view>
		<button @click="getvoucher" type="default" style="width: 90%;margin-left: 5%;background-color: #FE7273;margin-top: 30upx;color: #fff;font-weight: 550;">上传凭证</button>
	</view>
</template>

<script>
	export default {
		  data() {
		   return {
					id:'',
					bank:'',
					bankpeople:'',
					bankcard:'',
					avatar:'',
					backgroundImg:'../../../static/pz.png',
		   }
		  },
		  onLoad(options) {
				this.id = options.id
		    uni.getStorage({
		        key: 'openid',
		        success: (res)=> {
		           this.openid = res.data
		    			 this.getdata()
		        }
		    });
		  },
		  methods: {
				getdata(){
					uni.request({
						url: 'http://mall.zhongzhengyicai.com/app/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.bz_exchange.offlinepay&app=1',
						method: 'POST',
						data: {
							'openid':this.openid,
							'id' : this.id,
						},
						header:{'Content-Type':'application/x-www-form-urlencoded'},
						success:(res) => {
							console.log(res)
							this.bank = res.data.bank
							this.bankcard = res.data.bankcard
							this.bankpeople = res.data.bankpeople
						},
						fail: () => {},
						complete: () => {}
					});
				},
				getvoucher(){
					uni.request({
						url: 'http://mall.zhongzhengyicai.com/app/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.bz_exchange.offlinepay_sumbit&app=1',
						method: 'POST',
						data: {
							'openid':this.openid,
							'id' : this.id,
							'img' : this.avatar,
						},
						header:{'Content-Type':'application/x-www-form-urlencoded'},
						success:(res) => {
							console.log(res)
							uni.showToast({
								title:res.data.result.message,
								icon:'none'
							})
						},
						fail: () => {},
						complete: () => {}
					});
				},
				chooseImage(){
					var _this = this
					uni.chooseImage({
					    count: 1, //默认9
					    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					    sourceType: ['album'], //从相册选择
					    success: function (res) {
								let file = res.tempFilePaths
								var images = []
								var img = ''
								for(var i = 0; i<res.tempFilePaths.length; i++) {
									uni.uploadFile({
										url: 'http://mall.zhongzhengyicai.com/app/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=util.uploader&app=1',
										filePath: file[i],
										name: 'file',
										formData: {
											'user': 'test'
										},
										success: (res) => {
											images.push(JSON.parse(res.data).url)
											_this.imagess = images
											_this.avatar = _this.imagess
											
											img = img + JSON.parse(res.data).url + ';'
											_this.imgurl = img
											console.log(_this.avatar)
										}
									});
								}
					    }
					});
				}
				}
		 }
	</script>

<style>
</style>
